import request from '@/utils/request'

// ==================== 招新管理相关API ====================

// 查询招新列表
export function listRecruitment(query) {
  return request({
    url: '/campus/recruitment/list',
    method: 'get',
    params: query
  })
}

// 获取招新详细信息
export function getRecruitment(recruitmentId) {
  return request({
    url: '/campus/recruitment/' + recruitmentId,
    method: 'get'
  })
}

// 新增招新
export function addRecruitment(data) {
  return request({
    url: '/campus/recruitment',
    method: 'post',
    data: data
  })
}

// 修改招新
export function updateRecruitment(data) {
  return request({
    url: '/campus/recruitment',
    method: 'put',
    data: data
  })
}

// 删除招新
export function deleteRecruitment(recruitmentIds) {
  return request({
    url: '/campus/recruitment/' + recruitmentIds,
    method: 'delete'
  })
}

// 发布招新信息
export function publishRecruitment(data) {
  return request({
    url: '/campus/recruitment/publish',
    method: 'post',
    data: data
  })
}

// 关闭招新
export function closeRecruitment(recruitmentId) {
  return request({
    url: '/campus/recruitment/close/' + recruitmentId,
    method: 'put'
  })
}

// 重新开放招新
export function reopenRecruitment(recruitmentId) {
  return request({
    url: '/campus/recruitment/reopen/' + recruitmentId,
    method: 'put'
  })
}

// 根据社团ID查询招新列表
export function getRecruitmentsByClub(clubId) {
  return request({
    url: '/campus/recruitment/club/' + clubId,
    method: 'get'
  })
}

// 获取招新统计信息
export function getRecruitmentStatistics(recruitmentId) {
  return request({
    url: '/campus/recruitment/statistics/' + recruitmentId,
    method: 'get'
  })
}

// 获取社团招新统计
export function getClubRecruitmentStatistics(clubId) {
  return request({
    url: '/campus/recruitment/statistics/club/' + clubId,
    method: 'get'
  })
}

// 批量更新招新状态
export function batchUpdateRecruitmentStatus(data) {
  return request({
    url: '/campus/recruitment/batchUpdateStatus',
    method: 'put',
    data: data
  })
}

// 增加浏览量
export function increaseViewCount(recruitmentId) {
  return request({
    url: '/campus/recruitment/increaseView/' + recruitmentId,
    method: 'post'
  })
}

// 检查招新是否可申请
export function isRecruitmentAvailable(recruitmentId) {
  return request({
    url: '/campus/recruitment/checkAvailable/' + recruitmentId,
    method: 'get'
  })
}
